//
//  MSRegisterView.m
//  觅尚
//
//  Created by No.8 on 2019/3/19.
//  Copyright © 2019 No.8. All rights reserved.
//

#import "MSRegisterView.h"

@implementation MSRegisterView

/** 登录标题*/
- (UILabel *)registertitle {
    if (!_registertitle) {
        _registertitle = [[UILabel alloc] init];
        _registertitle.frame = CGRectMake(150 * px, 150 * px, 150 * px, 70 * px);
        _registertitle.text  = @"注册";
        _registertitle.textColor = [UIColor whiteColor];
        _registertitle.font = [UIFont boldSystemFontOfSize:SYRealValue(38 / 2)];
        [self addSubview:_registertitle];
        
    }
    return _registertitle;
}

/** 手机号输入框*/
- (UITextField *)iphoneTextField{
    if (!_iphoneTextField) {
        _iphoneTextField = [[UITextField alloc] init];
        _iphoneTextField.frame = CGRectMake(_registertitle.x, CGRectGetMaxY(_registertitle.frame) + 200 * px, (ScreenWidth - _registertitle.x * 2) / 1.5, 150 * px);
        _iphoneTextField.placeholder = @"请输入手机号";
        [_iphoneTextField setValue:[UIColor grayColor] forKeyPath:@"_placeholderLabel.textColor"];
        [_iphoneTextField setValue:[UIFont systemFontOfSize:SYRealValue(35 / 2)] forKeyPath:@"_placeholderLabel.font"];
        _iphoneTextField.keyboardType = UIKeyboardTypeNumberPad;
        _iphoneTextField.textColor = [UIColor whiteColor];
        [self addSubview:_iphoneTextField];
        
    }
    return _iphoneTextField;
    
}

/** 获取验证码按钮*/
- (UIButton *)codeButton {
    if (!_codeButton) {
        _codeButton = [[UIButton alloc] initWithFrame:CGRectMake(CGRectGetMaxX(_iphoneTextField.frame), _iphoneTextField.y, _iphoneTextField.width * 0.5, _iphoneTextField.height)];
        [_codeButton setTitle:@"获取验证码" forState:UIControlStateNormal];
        //        _codeButton.backgroundColor = [UIColor redColor];
        _codeButton.titleLabel.font = [UIFont systemFontOfSize:SYRealValue(35 / 2)];
        [_codeButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [self addSubview:_codeButton];
    }
    return _codeButton;
}


/** 账号下划线*/
- (UIImageView *)iphonelineIMG {
    if (!_iphonelineIMG) {
        _iphonelineIMG = [[UIImageView alloc] initWithFrame:CGRectMake(_iphoneTextField.x, CGRectGetMaxY(_iphoneTextField.frame), ScreenWidth - _registertitle.x * 2, 1)];
        _iphonelineIMG.image = [UIImage imageNamed:@"line"];
        [self addSubview:_iphonelineIMG];
        
    }
    return _iphonelineIMG;
}

/** 验证码输入框*/
- (UITextField *)codeTextField{
    if (!_codeTextField) {
        _codeTextField = [[UITextField alloc] init];
        _codeTextField.frame = CGRectMake(_registertitle.x, CGRectGetMaxY(_iphonelineIMG.frame) + 80 * px, _iphonelineIMG.width, _iphoneTextField.height);
        _codeTextField.placeholder = @"请输入验证码";
        _codeTextField.keyboardType = UIKeyboardTypeNumberPad;
        [_codeTextField setValue:[UIColor grayColor] forKeyPath:@"_placeholderLabel.textColor"];
        [_codeTextField setValue:[UIFont systemFontOfSize:SYRealValue(35 / 2)] forKeyPath:@"_placeholderLabel.font"];
        _codeTextField.textColor = [UIColor whiteColor];
        [self addSubview:_codeTextField];
        
    }
    return _codeTextField;
    
}


/** 密码下划线*/
- (UIImageView *)codelineIMG {
    if (!_codelineIMG) {
        _codelineIMG = [[UIImageView alloc] initWithFrame:CGRectMake(_iphoneTextField.x, CGRectGetMaxY(_codeTextField.frame), _iphonelineIMG.width, _iphonelineIMG.height)];
        _codelineIMG.image = [UIImage imageNamed:@"line"];
        [self addSubview:_codelineIMG];
        
    }
    return _codelineIMG;
}


/** 密码输入框*/
- (UITextField *)passworldTextField{
    if (!_passworldTextField) {
        _passworldTextField = [[UITextField alloc] init];
        _passworldTextField.frame = CGRectMake(_registertitle.x, CGRectGetMaxY(_codelineIMG.frame) + 80 * px, _iphonelineIMG.width - 80 * px, _iphoneTextField.height);
        _passworldTextField.placeholder = @"请输入密码";
        [_passworldTextField setValue:[UIColor grayColor] forKeyPath:@"_placeholderLabel.textColor"];
        [_passworldTextField setValue:[UIFont systemFontOfSize:SYRealValue(35 / 2)] forKeyPath:@"_placeholderLabel.font"];
        _passworldTextField.textColor = [UIColor whiteColor];
       _passworldTextField.secureTextEntry = YES;
        [self addSubview:_passworldTextField];
        
    }
    return _passworldTextField;
    
}


/** 密码下划线*/
- (UIImageView *)passworldlineIMG {
    if (!_passworldlineIMG) {
        _passworldlineIMG = [[UIImageView alloc] initWithFrame:CGRectMake(_iphoneTextField.x, CGRectGetMaxY(_passworldTextField.frame), _iphonelineIMG.width, _iphonelineIMG.height)];
        _passworldlineIMG.image = [UIImage imageNamed:@"line"];
        [self addSubview:_passworldlineIMG];
        
    }
    return _passworldlineIMG;
}

/** 密码可见按钮*/
- (UIButton *)passworldButton{
    if (!_passworldButton) {
        _passworldButton = [[UIButton alloc] init];
        _passworldButton.frame = CGRectMake(CGRectGetMaxX(_passworldTextField.frame), _passworldTextField.y + 35 * px, 80 * px, 80 * px);
        [_passworldButton setImage:[UIImage imageNamed:@"不可见"] forState:UIControlStateNormal];
        [_passworldButton setImage:[UIImage imageNamed:@"可见"] forState:UIControlStateSelected];
        [self addSubview:_passworldButton];
        
    }
    return _passworldButton;
    
}



/** 注册码输入框*/
- (UITextField *)registerTextField{
    if (!_registerTextField) {
        _registerTextField = [[UITextField alloc] init];
        _registerTextField.frame = CGRectMake(_registertitle.x, CGRectGetMaxY(_passworldlineIMG.frame) + 80 * px, _passworldlineIMG.width, _iphoneTextField.height);
        _registerTextField.placeholder = @"请输入注册码";
        [_registerTextField setValue:[UIColor grayColor] forKeyPath:@"_placeholderLabel.textColor"];
        [_registerTextField setValue:[UIFont systemFontOfSize:SYRealValue(35 / 2)] forKeyPath:@"_placeholderLabel.font"];
        _registerTextField.textColor = [UIColor whiteColor];
        [self addSubview:_registerTextField];
        
    }
    return _registerTextField;
    
}


/** 注册码下划线*/
- (UIImageView *)registerlineIMG {
    if (!_registerlineIMG) {
        _registerlineIMG = [[UIImageView alloc] initWithFrame:CGRectMake(_iphoneTextField.x, CGRectGetMaxY(_registerTextField.frame), _iphonelineIMG.width, _iphonelineIMG.height)];
        _registerlineIMG.image = [UIImage imageNamed:@"line"];
        [self addSubview:_registerlineIMG];
        
    }
    return _registerlineIMG;
}



/** 登录按钮*/
- (UIButton *)registerButton {
    if (!_registerButton) {
        _registerButton = [[UIButton alloc] initWithFrame:CGRectMake(_iphoneTextField.x, CGRectGetMaxY(_registerlineIMG.frame) + 120 * px, _iphonelineIMG.width, 120 * px)];
        _registerButton.layer.cornerRadius = _registerButton.height * 0.5;
        //        _LoginButton.backgroundColor = [UIColor whiteColor];
        [_registerButton setTitle:@"下一步" forState:UIControlStateNormal];
        //        _LoginButton.frame = CGRectMake(10, 50, 200, 44);
        
        CAGradientLayer *gradientLayer =  [CAGradientLayer layer];
        gradientLayer.frame = _registerButton.bounds;
        gradientLayer.cornerRadius = _registerButton.height * 0.5;
        gradientLayer.startPoint = CGPointMake(0, 0);
        //        gradientLayer
        gradientLayer.endPoint = CGPointMake(1, 0);
        gradientLayer.locations = @[@(0.2),@(1.0)];//渐变点
        [gradientLayer setColors:@[(id)[WYCRGBColor(96, 59, 152) CGColor],(id)[WYCRGBColor(202, 72, 114) CGColor]]];//渐变数组
        [_registerButton.layer addSublayer:gradientLayer];
        _registerButton.titleLabel.font = [UIFont systemFontOfSize:SYRealValue(36 / 2)];
        [self addSubview:_registerButton];
        
    }
    return _registerButton;
}

/** 注册码下划线*/
- (UILabel *)showTitle {
    if (!_showTitle) {
        _showTitle = [[UILabel alloc] initWithFrame:CGRectMake(_registerButton.x - 40 * px, CGRectGetMaxY(_registerButton.frame) + 30 * px, 360 * px, 40 * px)];
        _showTitle.text = @"用户注册即代表同意";
        _showTitle.textColor = BackViewColor;
//        _showTitle.backgroundColor = [UIColor redColor];
        _showTitle.textAlignment = NSTextAlignmentRight;
        _showTitle.font = [UIFont systemFontOfSize:SYRealValue(27 / 2)];
        [self addSubview:_showTitle];
        
    }
    return _showTitle;
}
/** 用户协议*/
- (UIButton *)userdelButton {
    if (!_userdelButton) {
        _userdelButton = [[UIButton alloc] initWithFrame:CGRectMake(CGRectGetMaxX(_showTitle.frame), _showTitle.y, 240 * px, _showTitle.height)];
        [_userdelButton setTitle:@"《用户协议》" forState:UIControlStateNormal];
        [_userdelButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        _userdelButton.titleLabel.font = _showTitle.font;
//        _userdelButton.backgroundColor = [UIColor redColor];
        [self addSubview:_userdelButton];
        
    }
    return _userdelButton;
}
/** 和*/
- (UILabel *)HeTitle {
    if (!_HeTitle) {
        _HeTitle = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(_userdelButton.frame), _showTitle.y, 40 * px, _showTitle.height)];
        _HeTitle.text = @"和";
        _HeTitle.textColor = BackViewColor;
//        _HeTitle.backgroundColor = [UIColor redColor];
        _HeTitle.textAlignment = NSTextAlignmentRight;
        _HeTitle.font = _showTitle.font;
        [self addSubview:_HeTitle];
        
    }
    return _HeTitle;
}


/** 用户协议*/
- (UIButton *)PrivacyButton {
    if (!_PrivacyButton) {
        _PrivacyButton = [[UIButton alloc] initWithFrame:CGRectMake(CGRectGetMaxX(_HeTitle.frame), _showTitle.y, _userdelButton.width, _showTitle.height)];
        [_PrivacyButton setTitle:@"《隐私协议》" forState:UIControlStateNormal];
        [_PrivacyButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        _PrivacyButton.titleLabel.font = _showTitle.font;
//        _PrivacyButton.backgroundColor = [UIColor redColor];
        [self addSubview:_PrivacyButton];
        
    }
    return _PrivacyButton;
}
/** 注册账号*/
- (UIButton *)LoginButton {
    if (!_LoginButton) {
        
        
        _LoginButton = [[UIButton alloc] initWithFrame:CGRectMake(ScreenWidth / 4, CGRectGetMaxY(_registerButton.frame) + 200 * px, ScreenWidth * 0.5, 100 * px)];
        _LoginButton.layer.cornerRadius = _iphoneTextField.height * 0.5;
        //        _choseButton.backgroundColor = [UIColor whiteColor];
        [_LoginButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [_LoginButton setTitle:@"我有账号，去登录" forState:UIControlStateNormal];
        _LoginButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
        _LoginButton.titleLabel.font = [UIFont systemFontOfSize:SYRealValue(35 / 2)];
        
        
        NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:_LoginButton.titleLabel.text];
        [_LoginButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [str addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(5,3)];
        _LoginButton.titleLabel.attributedText = str;
        [_LoginButton setAttributedTitle:str forState:UIControlStateNormal];
        [self addSubview:_LoginButton];
    }
    return _LoginButton;
}
- (id)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        
        //        self.backgroundColor = [UIColor ];
        [self CreateSubView];
    }
    return self;
}
- (void)CreateSubView{
    
    self.backgroundColor = [UIColor whiteColor];
    
    //    [self logintitle];
    
}

@end
